using UnityEngine;
using UnityEngine.UI;
using LitTools;
using System;

namespace LitToolsTest
{
    public partial class CubeItem : MonoBehaviour
    {
        public float totalLifeTime = 3;
        public float curLifeTime;
        public Action<CubeItem> lifeFinish;
        private void Update()
        {
            curLifeTime -= Time.deltaTime;
            if (curLifeTime <= 0)
                lifeFinish?.Invoke(this);
        }
    }

    public partial class CubeItem : IObjectPoolItem
    {
        public void OnBeforeRent()
        {
            curLifeTime = totalLifeTime;
            gameObject.SetActive(true);
        }

        public void OnBeforeReturn()
        {
            gameObject.SetActive(false);
        }

        public void OnRelease()
        {
            Destroy(gameObject);
        }

        public void OnCreate()
        {
            curLifeTime = totalLifeTime;
        }
    }
}